package com.example.jdbctemplateplusexample;

import io.gitee.cofenghen.jdbctempleplus.BaseJdbcTemplePlus;
import io.gitee.cofenghen.jdbctempleplus.config.EnableOrmTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@SpringBootApplication
@EnableOrmTemplate
public class JdbctemplatePlusExampleApplication {

    public static void main(String[] args){


    ConfigurableApplicationContext application = SpringApplication.run(JdbctemplatePlusExampleApplication.class, args);
        InetAddress localHost = null;
        try {
            localHost = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        Environment env = application.getEnvironment();
        log.info("\n----------------------------------------------------------\n\t" +
                "Application '{}' is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:{}\n\t" +
                "External: \thttp://{}:{}\n\t" +
                "Doc: \thttp://{}:{}/doc.html\n" +
                "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),
                //env.getProperty("spring.cloud.client.ip-address"),
                localHost.getHostAddress(),
                env.getProperty("server.port"),
               // env.getProperty("spring.cloud.client.ip-address"),
                localHost.getHostAddress(),
                env.getProperty("server.port"));

        BaseJdbcTemplePlus.registerDialect("Oracle",OracleServerSQLDialect::new);

    }

}
